home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 020a / anifra.zip / ANIFRA.C next >
C/C++ Source or Header  |  1991-10-09  |  7KB  |  269 lines

  1. /****************************************************************************/
  2. /* anifra.c, a program for generating parameter and batch files for use with*/
  3. /* FRACTINT. Written by Erkki Sondergaard [CI$ 100016,1620]. On YCCMR known */
  4. /* as Erkki Soendergaard. This program is hereby placed in public domain.   */
  5. /****************************************************************************/
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <math.h>
  10.  
  11. char center_opt, param_opt;
  12. char sound[4], video[5], gif87a[4], overwrite[4], passes[2], floatopt[4];
  13. char type[12], inside[8], outside[8], map[12], prefix[6];
  14. float param_x, param_y, param_end_x, param_end_y, param_radius;
  15. float center_x, center_y, center_end_x, center_end_y, center_radius;
  16. float start_mag, current_mag, zoom_mult, offset_x, offset_y;
  17. float step_param_x, step_param_y, step_center_x, step_center_y, step_circle;
  18. float current_param_x, current_param_y, current_center_x, current_center_y;
  19. int step, steps, intervals, current_interval, maxiter, bailout;
  20. FILE *parfile, *batfile;
  21. char parext[] = ".par";
  22. char batext[] = ".bat";
  23. char parname[11] = "";
  24. char batname[11] = "";
  25.  
  26. main()
  27. {
  28.     get_moveopt();
  29.     get_paropt();
  30.     get_batopt();
  31.     init_calc();
  32.     init_files();
  33.  
  34.  
  35.     for(step = 0;step < steps;step++)
  36.         {
  37.         calc_param();
  38.             calc_center();
  39.         write_par();
  40.         write_bat();
  41.         }
  42.  
  43.     fclose(batfile);
  44.     fclose(parfile);
  45.     credits();
  46. }
  47. get_moveopt()
  48. {
  49.     printf("\nMovement options works as follows:\n");
  50.     printf("Zoom keeps same center and applies the zoom factor to each frame.\n");
  51.     printf("Zoom only applies on center-mag.\n");
  52.     printf("Circle generates points on a circle and uses center and radius.\n");
  53.     printf("Circle starts on the top.\n");
  54.     printf("Line uses a straight line between 2 points/parameters.\n");
  55.     printf("Point keeps same point/parameter in all frames.\n");
  56.  
  57.     printf("\nEnter center movement option (z/c/l/p):");
  58.     fflush(stdin);
  59.     scanf("%c",¢er_opt);
  60.     fflush(stdin);
  61.  
  62.     printf("\nCenter/starting point X,Y ");
  63.     scanf("%f,%f",¢er_x,¢er_y);
  64.  
  65.     if (center_opt == 'z' || center_opt == 'Z') {
  66.         printf("\nEnter start magnification:");
  67.         scanf("%f",&start_mag);
  68.         printf("\nEnter zoom multiplication factor:");
  69.         scanf("%f",&zoom_mult);
  70.         }
  71.     else {
  72.         start_mag = 0.6666667;
  73.         zoom_mult = 1.0;
  74.         }
  75.  
  76.     if (center_opt == 'c' || center_opt == 'C') {
  77.         printf("\nEnter radius for center-circle:");
  78.         scanf("%f",¢er_radius);
  79.         }
  80.     else {
  81.         center_radius = 0.0;
  82.         }
  83.  
  84.     if (center_opt == 'l' || center_opt == 'L') {
  85.         printf("\nEnter center end point X,Y");
  86.         scanf("%f,%f",¢er_end_x,¢er_end_y);
  87.         }
  88.     else {
  89.         center_end_x = center_x;
  90.         center_end_y = center_y;
  91.         }
  92.  
  93.  
  94.     printf("\nEnter parameter movement option (c/l/p):");
  95.     fflush(stdin);
  96.     scanf("%c",¶m_opt);
  97.     fflush(stdin);
  98.     printf("\nEnter center/starting parameter point X,Y ");
  99.     scanf("%f,%f",¶m_x,¶m_y);
  100.  
  101.  
  102.     if (param_opt == 'c' || param_opt == 'C') {
  103.         printf("\nEnter radius for parameter circle:");
  104.         scanf("%f",¶m_radius);
  105.         }
  106.     else {
  107.         param_radius = 0.0;
  108.         }
  109.  
  110.     if (param_opt == 'l' || param_opt == 'L') {
  111.         printf("\nEnter parameter end point X,Y ");
  112.         scanf("%f,%f",¶m_end_x,¶m_end_y);
  113.         }
  114.     else {
  115.         param_end_x = center_x;
  116.         param_end_y = center_y;
  117.         }
  118.  
  119.     printf("\nEnter number of steps:");
  120.     scanf("%d",&steps);
  121. }
  122.  
  123. get_batopt()
  124. {
  125.     printf("\nBatch options. Will be included in the batch file. \n");
  126.     printf("\nEnter name prefix for files and names (max. 5 char):");
  127.     scanf("%s",&prefix);
  128.     printf("\nSound=");
  129.     scanf("%s",&sound);
  130.     printf("\nVideo=");
  131.     scanf("%s",&video);
  132.     printf("\nGif87a=");
  133.     scanf("%s",&gif87a);
  134.     printf("\nOverwrite=");
  135.     scanf("%s",&overwrite);
  136. }
  137. get_paropt()
  138. {
  139.     printf("\nCalculation options for the parameter file.");
  140.     printf("\n(see X menu in fractint for expected values)\n");
  141.     printf("\nPasses=");
  142.     scanf("%s",&passes);
  143.     printf("\nFloat=");
  144.     scanf("%s",&floatopt);
  145.     printf("\nType=");
  146.     scanf("%s",&type);
  147.     printf("\nMaxiter=");
  148.     scanf("%d",&maxiter);
  149.     printf("\nBailout=");
  150.     scanf("%d",&bailout);
  151.     printf("\nInside=");
  152.     scanf("%s",&inside);
  153.     printf("\nOutside=");
  154.     scanf("%s",&outside);
  155.     printf("\nMap=");
  156.     scanf("%s",&map);
  157. }
  158.  
  159. init_files()
  160. {
  161.     strcat(parname,prefix);
  162.     strcat(parname,parext);
  163.  
  164.     if((parfile = fopen(parname,"wt"))==NULL) {
  165.         printf("\nUnable to open %s file",parname);
  166.         exit(10);
  167.         }
  168.  
  169.     strcat(batname,prefix);
  170.     strcat(batname,batext);
  171.     if((batfile = fopen(batname,"wt"))==NULL) {
  172.         printf("\nUnable to open %s file",batname);
  173.         exit(10);
  174.         }
  175.     fprintf(batfile,"@rem batch file created by anifra\n");
  176.     fprintf(parfile,"/*parameter file created by anifra*/\n");
  177.  
  178. }
  179. write_par()
  180. {
  181.  
  182.   fprintf(parfile,"%s%03d {;%s no.%03d\n",prefix,step,type, step);
  183.   fprintf(parfile,"  reset type=%s params=%f/%f\n",
  184.       type,current_param_x,current_param_y);
  185.     fprintf(parfile,"  center-mag=%f/%f/%f\n",
  186.         current_center_x,current_center_y,current_mag);
  187.   fprintf(parfile,"  maxiter=%d bailout=%d passes=%s\n",
  188.         maxiter,bailout,passes);
  189.     fprintf(parfile,"  inside=%s outside=%s map=%s }\n",
  190.         inside,outside,map);
  191. }
  192. write_bat()
  193. {
  194.  
  195.   fprintf(batfile,"fractint @%s.par/%s%03d batch=y savename=%s%03d ",
  196.        prefix,prefix,step,prefix,step);
  197.   fprintf(batfile,"gif87a=%s video=%s overwrite=%s sound=%s\n",
  198.        gif87a,video,overwrite,sound);
  199. }
  200. init_calc()
  201. {
  202.     intervals = steps - 1;
  203.     step_param_x = (param_end_x - param_x) / intervals;
  204.     step_param_y = (param_end_y - param_y) / intervals;
  205.  
  206.     step_center_x = (center_end_x - center_x) / intervals;
  207.     step_center_y = (center_end_y - center_y) / intervals;
  208.     step_circle = (2.0 * 3.1415625) / steps;
  209.  
  210.     if (center_opt == 'z' || center_opt == 'Z') {
  211.        current_mag = start_mag / zoom_mult;
  212.        }
  213.     else
  214.        {
  215.        current_mag = start_mag;
  216.        }
  217.  
  218.     current_param_x = param_x;
  219.     current_param_y = param_y;
  220.     current_center_x = center_x;
  221.     current_center_y = center_y;
  222.  
  223. }
  224.  
  225. calc_param()
  226. {
  227.     if (param_opt == 'l' || param_opt == 'L') {
  228.         current_param_x = param_x + (step_param_x * step);
  229.       current_param_y = param_y + (step_param_y * step);
  230.         }
  231.     if (param_opt == 'c' || param_opt == 'C') {
  232.         offset_x=(sin( (step_circle * step)));
  233.       offset_y=(cos( (step_circle * step)));
  234.         current_param_x = param_x + (param_radius * offset_x);
  235.         current_param_y = param_y + (param_radius * offset_y);
  236.         }
  237.  
  238. }
  239. calc_center()
  240. {
  241.     if (center_opt == 'z' || center_opt == 'Z') {
  242.         current_mag = current_mag * zoom_mult;
  243.         }
  244.     if (center_opt == 'l' || center_opt == 'L') {
  245.         current_center_x = center_x + (step_center_x * step);
  246.       current_center_y = center_y + (step_center_y * step);
  247.         }
  248.     if (center_opt == 'c' || center_opt == 'C') {
  249.         offset_x=(sin( (step_circle * step)));
  250.       offset_y=(cos( (step_circle * step)));
  251.       current_center_x = center_x + (center_radius * offset_x);
  252.       current_center_y = center_y + (center_radius * offset_y);
  253.         }
  254.  
  255.  
  256.  
  257. }
  258. credits()
  259. {
  260.     printf("\n\n\n\nAnifra ver. 1.0 written by:\n\n");
  261.     printf("\nErkki Soendergaard");
  262.     printf("\n                       ");
  263.     printf("\nAarhusgade 44, 1 tv.   ");
  264.     printf("\nDK-2100 Copenhagen Oe. ");
  265.     printf("\nDenmark                ");
  266.     printf("\nEurope                 ");
  267.     printf("\n\nCIS [100016,1620]\n");
  268. }
  269.